#pragma once;
#include "ObjPtrBase.h"

class Object;

template<class T>
class ObjPtr : private ObjPtrBase
{
public:
	ObjPtr(Object* owner, T* ptr) :
	 ObjPtrBase(owner, ptr)
	{}

	void operator=(T* newPtr)
	{
		ObjPtrBase::operator=(static_cast<Object*>(newPtr));
	}

	T& operator*() const
	{
		return *static_cast<T*>(ptr);
	}

	T* operator->() const
	{
		return static_cast<T*>(ptr);
	}

	operator T*() const
	{
		return static_cast<T*>(ptr);
	}

	operator bool() const
	{
		return ObjPtrBase::get() != 0;
	}

private:
	ObjPtr(const ObjPtr&);
	ObjPtr& operator=(const ObjPtr&); 
};